<?php
/** 
 * Created by RisingSun. 
 * User: MarkSpace 
 * Date: 20210822
 * Time: 11:05 
 * 列表管理
 */
namespace app\finance\model;

use  app\finance\model\Model;
use  Mscore\Core\Lib\Upload;
use  app\finance\model\Common;

class Assets extends Model{
	
    private $account = 'user_account'; // 账户表
    private $role = 'sys_role';
    private $withdraw = 'user_withdraw'; // 兑换表
    

    private $error=['code'=>0,'msg'=>'fail'];
    private $success=['code'=>200,'msg'=>'success']; 

    /**
     * 提现列表
     * @param array $withdraw 
     * @param array $where 
     */ 
    public function withdraw($where=null,$page=1,$page_size=10){
        //列表
        $list['datalist']= Model::name($this->withdraw)
            ->alias('a')
            ->join($this->account.' b','a.aid=b.aid','left')
            ->field('a.*,b.realname,b.username')
            ->limit(($page-1)*$page_size,$page_size)
            ->where($where)
            ->select();
        foreach ($list['datalist'] as $key => $value) {
          
        }
        //数据总数
        $list['total']=Model::name($this->withdraw)
            ->alias('a')
            ->where($where)
            ->count('a.id');
        return $list;
    }

    /**
     *  账户列表
     * @param array $list 
     * @param array $where 
     */ 
    public function list($where=null,$page=1,$page_size=10){
        //列表
        $list['datalist']= Model::name($this->account)
            ->alias('a')
            ->join($this->role.' b','a.roletype=b.id', 'left')
            ->field(' a.*, b.title as type')
            ->where($where)
            ->limit(($page-1)*$page_size,$page_size)
            ->select();
        //数据总数
        $list['total']=Model::name($this->account)
            ->alias('a')
            ->where($where)
            ->count('a.aid');
        return $list;
    }

    /**
     * 账户信息
     * @param array $info 
     * @param array $where 
     */ 
    public function info($id=null,$field='*'){  
         return Model::name($this->account)
           ->field($field)
           ->where(['aid'=>$id])
           ->find();;
    }

}
